<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;指标目录
  </div>
  <div class="work">

    <div class="top">
    <!-- first-input -->
				<input nz-input placeholder="名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['display:like']" />

      <nz-button-group>
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
        </nz-button-group>
      </div>
    </div>

    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzShowPagination]="false" [nzFrontPagination]="false"
          [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing">
          <thead>
            <tr>
			  <th nzWidth="20%">名称</th>
			  <th nzWidth="20%">类型</th>
			  <th nzWidth="20%">是否有效</th>
              <th nzWidth="15%">操作</th>
            </tr>
          </thead>
          <tbody>
            <ng-template ngFor let-data [ngForOf]="fs.datas">
              <ng-template ngFor let-item [ngForOf]="fs.expandDataCache[data.id]">
                <tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)">
                  <td [nzIndentSize]="item.level*20" [nzShowExpand]="!item.leaf" [(nzExpand)]="item.expand"
                    (nzExpandChange)="fs.collapse(item,$event)">
                    <span class="form-edit" (click)="fs.editRow(item)">{{item.display}}</span>
                  </td>
            		<td>{{item.dictionarytypeName}}</td>
                  <td>{{item.valid | boolReform}}</td>
                  <td>
                    <a *ngIf="!item.leaf" (click)="fs.addRow(item)" class="form-button">新增子项</a>
                    <a nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntity(item)" nzPlacement="bottomRight"
                      class="form-button">删除</a>
                  </td>
                </tr>
              </ng-template>
            </ng-template>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false'
        [nzFooter]="null"
        [(nzVisible)]="fs.isEditVisible"
        (nzOnCancel)="fs.closeEdit()" >
        <form nz-form [nzLayout]="'inline'">
          <input nz-input [(ngModel)]="fs.er.id" type="hidden"
                 name="id" required #id="ngModel" />

          <input nz-input [(ngModel)]="fs.er.pid" type="hidden"
                 name="pid" required #pid="ngModel" />
			<div nz-row [nzGutter]="24">


                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">编号</nz-form-label>
                    <nz-form-control class="form-control" [nzValidateStatus]="code.invalid?'error':'success'" nzHasFeedback>
                      <input nz-input [(ngModel)]="fs.er.code"
                             name="code" required #code="ngModel" />
                    </nz-form-control>
                  </nz-form-item>
                </div><div nz-col [nzSpan]="12">
                <nz-form-item>

                  <nz-form-label nzRequired class="form-label">类型</nz-form-label>
                  <nz-form-control class="form-control" [nzValidateStatus]="directoryType.invalid?'error':'success'"
                                   nzHasFeedback>
                    <nz-select [(ngModel)]="fs.er.dictionarytype" name="dictionarytype" required
                               #directoryType="ngModel" (nzOpenChange)="dicTypeDic.load('0')" [nzPlaceHolder]="'请选择'">
                      <nz-option *ngFor="let option of dicTypeDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                      </nz-option>
                      <nz-option *ngIf="dicTypeDic.isLoading" nzDisabled nzCustomContent>
                        <i nz-icon type="loading"></i>加载中...
                      </nz-option>
                      <span *ngIf="!dicTypeDic.isLoaded">
                                      <nz-option [nzLabel]="fs.er.dictionarytypeName" [nzValue]="fs.er.dictionarytype">
                                      </nz-option>
                                    </span>
                    </nz-select>
                  </nz-form-control>
                </nz-form-item>
              </div>


            </div>

			<div nz-row [nzGutter]="24">


                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">显示名称</nz-form-label>
                    <nz-form-control class="form-control" [nzValidateStatus]="display.invalid?'error':'success'" nzHasFeedback>
                      <input nz-input [(ngModel)]="fs.er.display"
                             name="display" required #display="ngModel" />
                    </nz-form-control>
                  </nz-form-item>
                </div>


                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">排序值</nz-form-label>
                    <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'" nzHasFeedback>
                      <nz-input-number [(ngModel)]="fs.er.order"
                                       name="order" required #order="ngModel"
                                       [nzMin]="1" [nzMax]="100" [nzStep]="1" class="form-control">
                      </nz-input-number>
                    </nz-form-control>
                  </nz-form-item>
                </div>
            </div>


			<div nz-row [nzGutter]="24">
                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">有效</nz-form-label>
                    <nz-form-control class="form-control">
                      <nz-switch nzCheckedChildren="有" nzUnCheckedChildren="无" [(ngModel)]="fs.er.valid" name="valid">
                      </nz-switch>
                    </nz-form-control>
                  </nz-form-item>
                </div>

                <div nz-col [nzSpan]="24" class="form-button-align">
                  <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
                  <button nz-button nzType="primary"
                          [disabled]='id.invalid || code.invalid || directoryType.invalid || display.invalid || order.invalid'
                          (click)="checkleaf()" [nzLoading]="fs.isSaveing">保存</button>
                </div>
            </div>

        </form>
    </nz-modal>
  </div>
</div>
